package com.ssy.lingxi.common.constant.member;

import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;

/**
 * 平台后台 - 适用会员类型枚举
 * 参考 MemberLevelTypeEnum
 * @author yzc
 * @version 2.0.0
 * @date 2021/6/28
 */
public enum PlatformSuitableMemberEnum {

    /**
     * 新会员（平台会员） - 1
     * 上级为平台的会员,无任何角色,当天审核通过
     */
    NEW_PLATFORM_MEMBER(1, "新会员（平台会员）"),

    /**
     * 老会员（平台会员） - 2
     * 上级为平台的会员,无任何角色,非当天审核通过
     */
    OLD_PLATFORM_MEMBER(2, "老会员（平台会员）");

    private final Integer code;
    private final String message;

    PlatformSuitableMemberEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public static String getCodeMessage(Integer code) {
        PlatformSuitableMemberEnum tagEnum = Arrays.stream(PlatformSuitableMemberEnum.values()).filter(o -> o.getCode().equals(code)).findFirst().orElse(null);
        return tagEnum == null ? "" : tagEnum.getMessage();
    }

    public static PlatformSuitableMemberEnum toEnum(Integer value) {
        return Arrays.stream(PlatformSuitableMemberEnum.values()).filter(e -> e.getCode().equals(value)).findFirst().orElse(NEW_PLATFORM_MEMBER);
    }

    public Integer getCode() {
        return code;
    }

    public String getMessage() {
        return LanguageHolder.getName(this.getClass(), this.getCode());
    }
}